<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Post 请求</title>
</head>
<body>
<div id="app">

</div>

<script src="../../../../js/axios.js"></script>
<script type="module">
    import {createApp, onMounted} from "../../../../js/vue.esm-browser.js";

    let app = createApp({
        setup() {

            function postRequest() {
                axios.post(
                    "https://www.httpbin.org/post",
                    {
                        name: "abcque",
                        age: 18,
                        gender: "M",
                    }
                )
                    .then((response) => {
                        console.log(response);
                        // 字符串类型
                        console.log(typeof response.data.data);
                        // json 类型
                        console.log(typeof response.data.json);

                        console.log(JSON.parse(response.data.data));
                        console.log(response.data.json);
                    })
                    .catch((error) => {
                        console.log(error);
                    })
                    .finally()
            }

            onMounted(() => {
                postRequest()
            })
            return {}
        }
    })

    app.mount("#app")
</script>
</body>
</html>